win32: Allow querying names for metrics
authorBenjamin Otte <otte@redhat.com>
Sun, 21 Feb 2016 23:49:09 +0000 (00:49 +0100)
committerBenjamin Otte <otte@redhat.com>
Mon, 22 Feb 2016 03:37:56 +0000 (04:37 +0100)
gtk/gtkwin32draw.c
gtk/gtkwin32drawprivate.h

index 7590e09bdf564b7ff1ea770ac5ca8d63ac1074c9..16459ce3908628faf77e010a0132e937ad800726 100644 (file)
@@ -450,6 +450,34 @@ static struct {
   { "cxpaddedborder",      0, NULL }
 };
 
+const char *
+gtk_win32_get_sys_metric_name_for_id (gint id)
+{
+  if (id >= 0 && id < G_N_ELEMENTS (win32_default_metrics))
+    return win32_default_metrics[id].name;
+  else
+    return NULL;
+}
+
+int
+gtk_win32_get_sys_metric_id_for_name (const char *name)
+{
+  int i;
+
+  g_return_val_if_fail (name != NULL, -1);
+
+  for (i = 0; i < G_N_ELEMENTS (win32_default_metrics); i++)
+    {
+      if (win32_default_metrics[i].name == NULL)
+        continue;
+
+      if (g_str_equal (name, win32_default_metrics[i].name))
+        return i;
+    }
+
+  return -1;
+}
+
 int
 gtk_win32_get_sys_metric (gint id)
 {
index da8ce7c74e9004c3750bbe68c096888d128fa7b4..ad419ae67223db7ecedd384b65e14773aac50bb9 100644 (file)
@@ -167,6 +167,8 @@ void                    gtk_win32_get_theme_margins             (const char
                                                                  int             state,
                                                                  GtkBorder      *out_margins);
 
+const char *            gtk_win32_get_sys_metric_name_for_id    (gint            id);
+int                     gtk_win32_get_sys_metric_id_for_name    (const char     *name);
 int                     gtk_win32_get_sys_metric                (gint            id);
 
 const char *            gtk_win32_get_sys_color_name_for_id     (gint            id);